<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
	<div class="container">
		<a class="navbar-brand" href="#">my blog</a>
		<a class="navbar-brand" href="#">
			<div id="datetime">  
				<script>
        			setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
    			</script>
    		</div>	
		</a>
		<a class="navbar-brand">
			<div id="leavetime"  style="color:rgb(168, 154, 154)">  
				<script>
					var day_ = new Date('2022/11/4 00:00:00')
					var day_1 = new Date();
        			setInterval("document.getElementById('leavetime').innerHTML='距离2022年11月4日倒计时:'+Math.floor((day_-day_1)/1000/3600/24)+'天';", 1000);
    			</script>
    		</div>	
		</a>
		<div>
			<ul class="navbar-nav"> 
				<li class="nav-item">
					<a class="nav-link" href="{% url 'article:article_list' %}">文章</a>
				</li> 

				{% if user.is_authenticated %}
					<li class="nav-item dropdown">
						<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
							{{ user.username }}
						</a>
						<div class="dropdown-menu" aria-labelledby="navbarDropdown">
							<a class="dropdown-item" href='{% url "article:article_create" %}'>写文章</a>
							<a class="dropdown-item" href='{% url "userprofile:edit" user.id %}'>个人信息</a>
							<a class="dropdown-item" href="#" onclick="user_delete()">删除用户</a>
							<a class="dropdown-item" href='{% url "userprofile:logout" %}'>退出登录</a>
						</div>
					</li>
					<script>
						function user_delete(){
							layer.open({
								title:"危险操作",
								content:"确认删除用户资料么？",
								yes:function(index,layero){
									location.href='{% url "userprofile:delete" user.id %}'
								},
							})
						}
					</script>
				{% else %}
					<li class="nav-item">
						<a class="nav-link" href="{% url 'userprofile:login' %}">登录</a>
					</li>
				{% endif %}
			</ul>
		</div>

	</div>
 	
</nav>